<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: editresults.php 1126 2008-06-09 05:45:04Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
  function editResults($jl_func, $r, &$overall_config) {
    global $my, $mainframe, $database;
    global $joomleague;
    //$round = ($r == 0) ? $joomleague->current_round : $r;
    $round = $r;
	  $divid = mosGetParam($_REQUEST, 'division', 0);
    
    if(defined('JL_USER_IS_PROJECT_ADMIN') || defined('JL_USER_IS_PROJECT_EDITOR')
	  || defined('JL_USER_IS_BIG_BOSS') || $joomleague->isTeamEditor($round, $my->id)) {
	    define('JL_USER_HAS_ACCESS', TRUE);
	  }
	  
	  if (!defined('JL_USER_HAS_ACCESS')) {
	    echo 'This page is for administrative purposes ONLY! Good bye!<br />';
	  }
	  else {
	    define('JL_SHOW_EDIT_ICON', true);
	    $results_config=$joomleague->getTemplateConfig("show_results.tpl");
	    
	    //get matches
//	     $matches = $joomleague->getResults($round, 'ASC', 1);
	    $matches = $joomleague->getResultsRows( $round, $divid, $results_config );
	    //get teams
	    //$resultTeams = $joomleague->getTeamsIndexedById(null, $divid)
	    $resultTeams = $joomleague->getTeamsIndexedById(); ; 
	    
	    $rounds=$joomleague->getRoundNames();
	    $pageNav=$joomleague->pagenav($jl_func,count($rounds), $round);
		  $pageNav2=$joomleague->pagenav2($jl_func,count($rounds), $round);
		  $current_round=$round;
	
      define('JL_EDIT_MODE', true);
      require_once( JL_FRONTEND_PATH . '/js/JL_frontediting.js.php' );
		  
      $mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="'
		            ._JOOMLA_JL_LIVE_SITE.'/includes/js/calendar/calendar-mos.css" title="green" />');
      $mainframe->addCustomHeadTag('<link rel="stylesheet" type="text/css" media="all" href="'
                ._JOOMLA_JL_LIVE_SITE.'/components/com_joomleague/css/joomleague.css" />');
		  
		  // prepare editor
		  $mainframe->set( 'loadEditor', true );
		  if ( file_exists( _JOOMLA_JL_PATH . '/editor/editor.php' ) ) {
			  require_once( _JOOMLA_JL_PATH . '/editor/editor.php' ); 
			}
			else {
			  require_once (_JOOMLA_JL_PATH . "/libraries/joomla/html/editor.php");
			}		  
		  initEditor();
		  
		  require(getTemplateFile(JL_TEMPLATE_PATH, 'edit_results_advanced.tpl.php'));
	  }
}
?>
